package com.gugee.tiktok.data.consumer.fansportrait.config;

import com.gugee.tiktok.data.common.config.KafkaProducerCommon;
import com.gugee.tiktok.data.common.msg.BloggerMessage;
import com.gugee.tiktok.data.common.msg.FansPortraitMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.annotation.EnableKafka;
import org.springframework.kafka.core.KafkaTemplate;


/**
 * Description:
 * User: Huang xin
 * Date: 2020-11-12 18:06
 */
@Configuration
@EnableKafka
public class KafkaProducerFansPortraitConfig {
    @Autowired
    KafkaProducerCommon kafkaProducerCommon;

    @Bean
    public KafkaTemplate<Long, FansPortraitMessage> kafkaTemplateFansPortrait() {
        return new KafkaTemplate<>(kafkaProducerCommon.myKafkaProducerFactory(FansPortraitMessage.MsgSerializer.class));
    }

    @Bean
    @ConditionalOnMissingBean
    public KafkaTemplate<Long, BloggerMessage> kafkaTemplateBlogger() {
        return new KafkaTemplate<>(kafkaProducerCommon.myKafkaProducerFactory(BloggerMessage.MsgSerializer.class));
    }
}
